夸克分享2[合].js 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  1. /*
  2. * 传参 ?type=url&params=../json/夸克分享.json@夸克分享[盘]
  3. * {"classes":[{"type_name":"花生十三","type_id":"8dd332256252"},{"type_name":"食谱","type_id":"78414690490e"},{"type_name":"体育","type_id":"25bf5b71edbb"}],"cookie":"__puus=0d26f820dbe87c2ff7689eca16d33dbdAATbA+y7U6E45kIqf3tUJD3ubw3yiLFUneh7o2z7qsn/vNtt13XnX5nq24o8c1PFNiaRXf9lCjyU8a8OHOwiWUwyB2awYMF3Q3KeegYcdEvy8ND7sRa0vlDQ1nPIWdR0BZD52AXBQj5UBIy0E2yknnBf+bzag4ivcZLepQskKRVGJ8tlB7jy8sgOem4zOP0cxKCMZLmwUeeaKFzdCnlhqj9+;__pus=69d93c40091ac35657fcdad30c901d8fAATxYe3kuhbmWR/i/UY5HxwQQPHPfx2Y/oEUXCA5LbTk2cvg8UqI6jwVZs1vlK34HoJ6KsjzHygZE3SbMoQVW2g6;__kp=c9e05ec0-8574-11ef-8fbe-77ecc2a14af3"}
  4. */
  5. globalThis.getdata = function () { }
  6. globalThis.getjl = []
  7. globalThis.getobj = {}
  8. globalThis.getvod = []
  9. var rule = {
  10. author: '嗷呜',
  11. title: '夸克合集',
  12. host: 'https://drive.quark.cn',
  13. url: '/1/clouddrive/share/sharepage/token?pr=ucpro&fr=pc',
  14. filterable: 1,
  15. searchable: 2,
  16. quickSearch: 0,
  17. params: 'http://127.0.0.1:9978/file/tvbox/js/json/夸克分享.json',
  18. headers: {
  19. 'Origin': 'https://pan.quark.cn',
  20. 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) quark-cloud-drive/2.5.20 Chrome/100.0.4896.160 Electron/18.3.5.4-b478491100 Safari/537.36 Channel/pckk_other_ch',
  21. 'Referer': 'http://pan.quark.cn/',
  22. 'Content-Type': 'application/json',
  23. 'Cookie': ''
  24. },
  25. hikerListCol: "avatar",
  26. play_parse: true,
  27. lazy: $js.toString(() => {
  28. function sleep(milliseconds) {
  29. var start = new Date().getTime();
  30. var end = 0;
  31. while ((end - start) < milliseconds) {
  32. end = new Date().getTime();
  33. }
  34. }
  35. let fg = input.split('|||www')
  36. let save_as_top_fids = fg[1]
  37. function findValue(char) {
  38. if (getjl.length === 0) {
  39. return null;
  40. }
  41. for (let item of getjl) {
  42. if (item.key === char) {
  43. return item.value;
  44. }
  45. }
  46. return null;
  47. }
  48. let play = findValue(fg[1])
  49. if (fg[0] !== 'self' && !play) {
  50. if(getobj['zctoken']===null)
  51. {
  52. let pdirpath = '/1/clouddrive/file/sort?pr=ucpro&fr=pc&uc_param_str&pdir_fid=0&_page=1&_size=50&_fetch_total=1&_fetch_sub_dirs=0&_sort=file_type:asc,file_name:asc'
  53. let pdirdata = getdata(pdirpath, 'GET', '').data.list
  54. for (let i = 0; i < pdirdata.length; i++) {
  55. if (pdirdata[i].file_name === '0000temp' || pdirdata[i].file_name === '来自:分享') {
  56. getobj['zctoken'] = pdirdata[i].fid
  57. break;
  58. }
  59. }
  60. }
  61. let pdir = getobj['zctoken']
  62. let body = { "fid_list": [fg[1]], "fid_token_list": [fg.slice(-1)[0]], "to_pdir_fid": pdir, "pwd_id": fg[0], "stoken": getobj[fg[0]].stoken, "pdir_fid": "0" }
  63. let task_path = '/1/clouddrive/share/sharepage/save?pr=ucpro&fr=pc'
  64. let task_id = getdata(task_path, 'POST', body).data.task_id
  65. for (let i = 0; i < 10; i++) {
  66. sleep(2000)
  67. let datapath = `/1/clouddrive/task?pr=ucpro&fr=pc&task_id=${task_id}&retry_index=1`
  68. let data = getdata(datapath, 'GET', '').data.save_as.save_as_top_fids
  69. if ((data.length > 0)) {
  70. save_as_top_fids = data[0]
  71. break;
  72. }
  73. }
  74. }
  75. if (!play) {
  76. play = []
  77. function ddd() {
  78. let body1 = { "fid": save_as_top_fids, "resolutions": "normal,low,high,super,2k,4k", "supports": "fmp4,m3u8" }
  79. let pldpath = '/1/clouddrive/file/v2/play?pr=ucpro&fr=pc'
  80. let pldata = getdata(pldpath, 'POST', body1).data.video_list
  81. pldata.forEach(it => {
  82. if (it.video_info.width && it.video_info.url) {
  83. play.push(it.video_info.width.toString(), it.video_info.url)
  84. }
  85. })
  86. }
  87. for (let i = 0; i < 10; i++) {
  88. sleep(2000)
  89. try {
  90. ddd()
  91. break;
  92. } catch {
  93. play = []
  94. }
  95. }
  96. let body1 = { 'fids': [save_as_top_fids] }
  97. let pldpath = '/1/clouddrive/file/download?pr=ucpro&fr=pc'
  98. let pldata1 = getdata(pldpath, 'POST', body1).data[0]
  99. play.unshift(pldata1.video_max_resolution,pldata1.download_url)
  100. let scpath='https://drive-pc.quark.cn/1/clouddrive/file/delete?pr=ucpro&fr=pc'
  101. let scbody={"action_type":2,"filelist":[save_as_top_fids],"exclude_fids":[]}
  102. let tsid=getdata(scpath,'POST',scbody).data.task_id
  103. let scurl=`https://drive-pc.quark.cn/1/clouddrive/task?pr=ucpro&retry_index=1&task_id=${tsid}&fr=pc`
  104. let scxy=getdata(scurl,'GET','')
  105. function sxjl() {
  106. if (getjl.length === getobj['plays']) {
  107. getjl.pop();
  108. }
  109. getjl.unshift({ key: fg[1], value: play });
  110. }
  111. let sx = sxjl()
  112. }
  113. let header = rule.headers
  114. delete header['Content-Type']
  115. input = {
  116. url: play,
  117. parse: 0,
  118. header: header
  119. }
  120. }),
  121. 预处理: $js.toString(() => {
  122. let html = request(rule.params);
  123. let json = dealJson(html);
  124. let cookie=json.cookie
  125. if(cookie.startsWith('file')){
  126. let scok=cookie
  127. cookie = request("http://127.0.0.1:9978/" + scok)
  128. if(scok.endsWith('json')){
  129. cookie=dealJson(cookie)['quark_cookie']
  130. }
  131. }
  132. if(!cookie){
  133. let hhd={'User-Agent':'Apache-HttpClient/UNAVAILABLE (java 1.4)'}  
  134. let dxcurl = 'http://api.v6x.wht.dgwht.top/text/3de88d10d01929be/'
  135. let xcdata = ['659db3c589771ac1', '0c5534049b55f2cc', '5f178ddd3fd5dbec']
  136. let dxc = []
  137. let yscookie=''
  138. for(let i=0;i<xcdata.length;i++){
  139. let data=fetch(dxcurl+xcdata[i],{headers:hhd})
  140. if (data.length > 10) {
  141. yscookie = data.slice(1, -1);
  142. break;
  143. }
  144. }
  145. cookie=yscookie
  146. }
  147. rule_fetch_params.headers.Cookie = cookie
  148. let data = json.classes
  149. let self = {
  150. "type_name": "我的夸克",
  151. "type_id": "self"
  152. }
  153. data.unshift(self)
  154. data.forEach(item => {
  155. getobj[item.type_id] = {};
  156. });
  157. getobj['plays']=json.plays||10
  158. getobj['zctoken']=null
  159. getdata = function (path, meth, body) {
  160. let url=HOST + path
  161. if(path.startsWith('http')){
  162. url=path
  163. }
  164. let data = fetch(url, {
  165. method: meth,
  166. headers: rule.headers,
  167. body: body
  168. })
  169. let jsdata = JSON.parse(data)
  170. return jsdata
  171. }
  172. rule.classes = data;
  173. }),
  174. class_parse: $js.toString(() => {
  175. input = rule.classes;
  176. }),
  177. 一级: $js.toString(() => {
  178. let vodd = []
  179. let wc = '|||www'
  180. let pdtoken = MY_CATE.split(wc)
  181. let pg=MY_PAGE
  182. let pwd_id = pdtoken[0].toString()
  183. if (pdtoken.length == 1 && pwd_id !== 'self') {
  184. let body = { "pwd_id": pwd_id, "passcode": "" }
  185. let data = getdata('/1/clouddrive/share/sharepage/token?pr=ucpro&fr=pc', 'POST', body)
  186. let stoken = data.data.stoken
  187. getobj[pwd_id].stoken = stoken
  188. let path = `/1/clouddrive/share/sharepage/detail?pr=ucpro&fr=pc&pwd_id=${pwd_id}&stoken=${encodeURIComponent(stoken)}&pdir_fid=0&force=0&_page=${pg}&_size=50&_fetch_banner=1&_fetch_share=1&_fetch_total=1&_sort=file_type:asc,updated_at:desc`
  189. let fids = getdata(path, 'GET', '').data.list
  190. getobj[pwd_id].fid = fids[0].fid
  191. } else if (pdtoken.length > 1) {
  192. getobj[pwd_id].fid = pdtoken[1]
  193. }
  194. getobj[pwd_id].pg = pg
  195. let path=''
  196. if(getobj[pwd_id].pg ==1 && pwd_id==='self' && pdtoken.length == 1){
  197. path = "/1/clouddrive/file/sort?pr=ucpro&fr=pc&uc_param_str=&pdir_fid=0&_page=1&_size=50&_fetch_total=1&_fetch_sub_dirs=0&_sort=file_type:asc,file_name:asc"
  198. }else if(pdtoken.length > 1 && pwd_id === 'self') {
  199. path = `/1/clouddrive/file/sort?pr=ucpro&fr=pc&uc_param_str=&pdir_fid=${getobj[pwd_id].fid}&_page=${getobj[pwd_id].pg}&_size=50&_fetch_total=1&_fetch_sub_dirs=0&_sort=file_type:asc,file_name:asc`
  200. } else if(pwd_id !== 'self'){
  201. path = `/1/clouddrive/share/sharepage/detail?pr=ucpro&fr=pc&pwd_id=${pwd_id}&stoken=${encodeURIComponent(getobj[pwd_id].stoken)}&pdir_fid=${getobj[pwd_id].fid}&force=0&_page=${getobj[pwd_id].pg}&_size=50&_fetch_banner=1&_fetch_share=1&_fetch_total=1&_sort=file_type:asc,file_name:asc`
  202. }
  203. let lbdata = getdata(path, 'GET', '')
  204. let lbsz = lbdata.data.list;
  205. lbsz.forEach(it => {
  206. let pdsp = it.format_type;
  207. if (pdsp.includes('video')) {
  208. let enji = pwd_id + wc + it.fid + wc + it.file_name + (it.share_fid_token ? (wc + it.share_fid_token) : '')
  209. vodd.push({
  210. vod_id: enji,
  211. vod_name: it.file_name,
  212. vod_pic: it.preview_url
  213. })
  214. } else if (pdsp === "") {
  215. vodd.push({
  216. vod_id: pwd_id + wc + it.fid,
  217. vod_name: it.file_name,
  218. vod_pic: 'https://gitee.com/amg99/tvjson/raw/master/img/kkwjj.png',
  219. vod_tag: 'folder'
  220. })
  221. }
  222. })
  223. if(getobj[pwd_id].pg==1&&vodd.length>0){
  224. getvod=vodd
  225. }else{
  226. Array.prototype.push.apply(getvod, vodd)
  227. }
  228. VODS = vodd
  229. }),
  230. 二级: $js.toString(() => {
  231. let xl = []
  232. getvod.forEach(it => {
  233. if (!it.vod_tag) {
  234. xl.push(it.vod_name + '$' + it.vod_id)
  235. }
  236. })
  237. VOD = {
  238. vod_play_from: '夸克预存原画',
  239. vod_play_url: xl.join('#')
  240. }
  241. }),
  242. }